﻿using System.Collections.Generic;
using System.ComponentModel;
using LiveTiss.Classes;

namespace LiveTiss.Schemas
{
    [System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://www.ans.gov.br/padroes/tiss/schemas")]
    public partial class ct_atendimentoConsulta : IDataErrorInfo
    {
        #region Public Properties - Custom

        [System.Xml.Serialization.XmlIgnoreAttribute()]
        public System.DateTime? _dataAtendimento
        {
            get
            {
                if (dataAtendimentoField > Util.EmptyDate)
                    return this.dataAtendimentoField;
                else
                    return null;
            }
            set
            {
                if (value.HasValue)
                {
                    if ((object.ReferenceEquals(this.dataAtendimentoField, value.Value) != true))
                    {
                        this.dataAtendimentoField = value.Value;
                        this.OnPropertyChanged("dataAtendimento");
                    }
                }
                else
                {
                    if ((object.ReferenceEquals(this.dataAtendimentoField, Util.EmptyDate) != true))
                    {
                        this.dataAtendimentoField = Util.EmptyDate;
                        this.OnPropertyChanged("dataAtendimento");
                    }
                }
            }
        }

        [System.Xml.Serialization.XmlIgnoreAttribute()]
        public List<KeyValuePair<string, string>> consultaItems
        {
            get
            {
                return XML_enum.TipoConsulta;
            }
        }

        [System.Xml.Serialization.XmlIgnoreAttribute()]
        public List<KeyValuePair<string, string>> saidaItems
        {
            get
            {
                return XML_enum.TipoSaidaGuiaConsulta;
            }
        }

        #endregion

        #region IDataErrorInfo

        private string _error = null;

        [System.Xml.Serialization.XmlIgnoreAttribute()]
        public string Error { get { return _error; } }

        [System.Xml.Serialization.XmlIgnoreAttribute()]
        public string this[string propertyName]
        {
            get
            {
                _error = null;
                switch (propertyName)
                {
                    case "_dataAtendimento":
                        if (!_dataAtendimento.HasValue)
                        {
                            _error = "Campo Obrigatório";
                        }
                        break;
                    case "procedimento":
                        if (procedimentoField == null)
                        {
                            _error = "Campo Obrigatório";
                        }
                        break;
                }

                return _error;
            }
        }

        #endregion
    }
}
